package com.zhijian.medical.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONUtil;
import com.google.common.collect.Lists;
import com.zhijian.medical.dao.local.AssessmentPaperMapper;
import com.zhijian.medical.entity.dto.DscScoreDto;
import com.zhijian.medical.entity.dto.ExamCreateAnswerJsonDto;
import com.zhijian.medical.entity.po.*;
import com.zhijian.medical.entity.vo.request.*;
import com.zhijian.medical.entity.vo.response.*;
import com.zhijian.medical.enums.AssessmentPersonStatusEnum;
import com.zhijian.medical.enums.ExamStatusEnum;
import com.zhijian.medical.holder.CurrentUserHolder;
import com.zhijian.medical.service.*;
import com.zhijian.medical.util.AssertUtil;
import com.zhijian.medical.util.JsonUtil;
import com.zhijian.medical.util.Page;
import com.zhijian.medical.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 考核-试卷模块业务处理层
 *
 * @author HCG
 * @version: 1.0
 * @date 2023-02-01 10:34:52
 */
@Slf4j
@Service
public class AssessmentPaperServiceImpl implements AssessmentPaperService {

    @Autowired
    private AssessmentPaperMapper mapper;

    /**
     * 默认题目数量
     */
    @Value("${exam.questionNum}")
    private Integer questionNum;

    @Autowired
    private ExamQuestionService examQuestionService;

    @Autowired
    private ExamAnswerService examAnswerService;

    @Autowired
    private AssessmentPaperQuestionService assessmentPaperQuestionService;

    @Autowired
    private AssessmentPaperPersonResultService assessmentPaperPersonResultService;

    @Autowired
    private DigitalSliceCaseService digitalSliceCaseService;

    @Autowired
    private AssessmentService assessmentService;

    @Autowired
    private AssessmentPaperPersonService assessmentPaperPersonService;

    @Autowired
    private AssessmentDscPaperPersonService assessmentDscPaperPersonService;

    @Autowired
    private AssessmentPaperService assessmentPaperService;

    private static List<String> options = null;

    static {
        //最大8个选项
        options = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
    }

    @Override
    public AssessmentPaper selectById(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public AssessmentPaperVo selectVoById(Long id) {
        return mapper.selectVoById(id);
    }

    @Override
    public void deleteById(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public void deleteByAssessmentId(Long assessmentId) {
        mapper.deleteByAssessmentId(assessmentId);
    }

    @Override
    public Long insert(AssessmentPaper assessmentPaper) {
        Date now = new Date();
        assessmentPaper.setCreateTime(now);
        assessmentPaper.setUpdateTime(now);
        return mapper.insert(assessmentPaper) > 0 ? assessmentPaper.getId() : 0L;
    }

    @Override
    public boolean update(AssessmentPaper assessmentPaper) {
        Date now = new Date();
        assessmentPaper.setUpdateTime(now);
        return mapper.updateByPrimaryKey(assessmentPaper) != 0;
    }

    @Override
    public boolean updateByPrimaryKeySelective(AssessmentPaper record) {
        Date now = new Date();
        record.setUpdateTime(now);
        return mapper.updateByPrimaryKeySelective(record) != 0;
    }

    @Override
    public Integer count(AssessmentPaperSearchVo assessmentPaperSearchVo) {
        return mapper.count(assessmentPaperSearchVo);
    }

    @Override
    public List<AssessmentPaperVo> selectList(AssessmentPaperSearchVo assessmentPaperSearchVo) {
        return mapper.selectList(assessmentPaperSearchVo);
    }

    @Override
    public Page<AssessmentPaperVo> selectPage(AssessmentPaperSearchVo assessmentPaperSearchVo) {
        //先直接查总数
        int count = count(assessmentPaperSearchVo);
        //分页
        Page<AssessmentPaperVo> page = new Page<>(true, count, assessmentPaperSearchVo.getPageNum(), assessmentPaperSearchVo.getPageSize());
        assessmentPaperSearchVo.setStartIndex(page.getStartIndex());
        page.setPage(true);
        page.setTotalCount(count);
        List<AssessmentPaperVo> responseVos = this.selectList(assessmentPaperSearchVo);
        page.setData(responseVos);
        return page;
    }

    @Override
    public boolean insertBatch(List<AssessmentPaper> entities) {
        return CollectionUtil.isNotEmpty(entities) && mapper.insertBatch(entities) > 0;
    }

    @Override
    public AssessmentPaper selectByUserIdAndAssessmentId(Long userId, Long assessmentId) {
        return mapper.selectByUserIdAndAssessmentId(userId, assessmentId);
    }

    @Transactional(rollbackFor = Exception.class, value = "localTransactionManager")
    @Override
    public Long generate(AssessmentStartVo assessmentStartVo) {
        //考核id
        Long assessmentId = assessmentStartVo.getAssessmentId();
        AssessmentPaper assessmentPaper = AssessmentPaper.builder()
                .warehouseId(assessmentStartVo.getWarehouseId())
                .assessmentId(assessmentId)
                .build();

        Date now = new Date();

        Set<String> randomEleSet = RandomUtil.randomEleSet(CollUtil.newArrayList("a", "b", "c", "d", "e", "f", "g", "h", "I", "J", "K", "L", "M", "N", "O", "P", "Q",
                "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"), 6);
        //六位随机数，随机数规则：字母支持大小写与数字结合
        String code = String.format("%s%s", DateUtil.format(now, new SimpleDateFormat("yyyyMMddHHmmss")),
                Arrays.toString(randomEleSet.toArray()).replace(",", "").replace("[", "").replace("]", "").replace(" ", "").trim());
        //考核唯一编码
        assessmentPaper.setCode(code);
        //考试人
        assessmentPaper.setUserId(assessmentStartVo.getUserId());
        //状态为未提交
        assessmentPaper.setStatus(ExamStatusEnum.UN_SUBMIT.getCode().byteValue());
        //多个切片类型
        String digitalSliceCaseType = assessmentStartVo.getDigitalSliceCaseType();
        assessmentPaper.setDigitalSliceCaseType(digitalSliceCaseType);

        //切片病例ID数组
        List<Long> dscIds = Lists.newArrayList();
        if (StringUtils.isNotBlank(digitalSliceCaseType)) {
            //如果有切片类型，则在这些类型中的病例中随机抽取病例
            List<DigitalSliceCaseVo> digitalSliceCaseVos = digitalSliceCaseService.selectListOnly(DigitalSliceCaseSearchVo.builder()
                    .typeList(Arrays.asList(digitalSliceCaseType.split(",")))
                    .userType(assessmentStartVo.getUserType())
                    .build());
            AssertUtil.check(assessmentStartVo.getDscNum() > digitalSliceCaseVos.size(), String.format("系统中存在的病例数目小于%s，无法通过", assessmentStartVo.getDscNum()));
            dscIds = digitalSliceCaseVos.stream().map(DigitalSliceCaseVo::getId).collect(Collectors.toList());
            //从中随机筛选出固定的数量来
            dscIds = RandomUtil.randomEleList(dscIds, assessmentStartVo.getDscNum());
            assessmentPaper.setDigitalSliceCaseIds(StrUtil.join(",", dscIds));
        } else if (StringUtils.isNotBlank(assessmentStartVo.getGroupIds())) {
            //如果有切片组，则在这些类型中的病例中随机抽取病例
            List<DigitalSliceCaseVo> digitalSliceCaseVos = digitalSliceCaseService.selectListOnly(DigitalSliceCaseSearchVo.builder()
                    .groupIdList(Arrays.stream(assessmentStartVo.getGroupIds().split(",")).map(Long::valueOf).collect(Collectors.toList()))
                    .userType(assessmentStartVo.getUserType())
                    .build());
            AssertUtil.check(assessmentStartVo.getDscNum() > digitalSliceCaseVos.size(), String.format("系统中存在的病例数目小于%s，无法通过", assessmentStartVo.getDscNum()));
            dscIds = digitalSliceCaseVos.stream().map(DigitalSliceCaseVo::getId).collect(Collectors.toList());
            //从中随机筛选出固定的数量来
            dscIds = RandomUtil.randomEleList(dscIds, assessmentStartVo.getDscNum());
            assessmentPaper.setDigitalSliceCaseIds(StrUtil.join(",", dscIds));
        }
        //随机挑符合预期目标的题目id出来
        Set<String> questionIdsSet = new HashSet<>();
        if (Objects.nonNull(assessmentStartVo.getWarehouseId())) {
            //问题id集合
            String ids = examQuestionService.selectIds(assessmentPaper.getWarehouseId());
            questionIdsSet = RandomUtil.randomEleSet(CollUtil.newArrayList(ids.split(",")), assessmentStartVo.getSingleSelectionNum());

            assessmentPaper.setQuestionIds(Arrays.toString(questionIdsSet.toArray()).replace(" ", "").replace("[", "").replace("]", "").trim());

        }
        //保存试卷，得到试卷id
        Long assessmentPaperId = this.insert(assessmentPaper);

        if (CollectionUtil.isNotEmpty(dscIds)) {
            //如果有病例题目，则批量保存病例做题数据
            List<AssessmentDscPaperPerson> assessmentDscPaperPersonList = dscIds.stream().map(dscId -> {
                AssessmentDscPaperPerson assessmentDscPaperPerson = new AssessmentDscPaperPerson();
                assessmentDscPaperPerson.setAssessmentPaperId(assessmentPaperId);
                assessmentDscPaperPerson.setUserId(assessmentStartVo.getUserId());
                assessmentDscPaperPerson.setCaseId(dscId);
                assessmentDscPaperPerson.setAssessmentId(assessmentId);
                assessmentDscPaperPerson.setStatus(AssessmentPersonStatusEnum.UN_SUBMIT.getCode().byteValue());
                assessmentDscPaperPerson.setCreateTime(now);
                assessmentDscPaperPerson.setUpdateTime(now);
                return assessmentDscPaperPerson;
            }).collect(Collectors.toList());
            assessmentDscPaperPersonService.insertBatch(assessmentDscPaperPersonList);
        }

        if (Objects.nonNull(assessmentStartVo.getWarehouseId()) && CollectionUtil.isNotEmpty(questionIdsSet)) {
            questionIdsSet.forEach(questionId -> {
                //题目ID
                Long qId = Long.valueOf(questionId);
                //找出这个题目的所有答案
                List<ExamAnswerVo> examAnswerVos = examAnswerService.selectList(ExamAnswerSearchVo.builder()
                        .questionId(qId)
                        .build());
                if (!CollectionUtils.isEmpty(examAnswerVos)) {
                    if (examAnswerVos.size() > 1) {
                        //说明是选择题，要随机排答案
                        List<ExamCreateAnswerJsonDto> examCreateAnswerJsonDtoList = new ArrayList<>();
                        //不确定有几个选项，所以取答案与自定义选项的最小值
                        int maxSize = options.size() > examAnswerVos.size() ? examAnswerVos.size() : options.size();
                        for (int i = 0; i < maxSize; i++) {
                            ExamAnswerVo examAnswerVo;
                            //随机数，在上述最小值内随机取答案
                            int randomInt;
                            do {
                                randomInt = RandomUtil.randomInt(maxSize);
                                examAnswerVo = examAnswerVos.get(randomInt);
                            } while (Objects.isNull(examAnswerVo));
                            //取得一个后，把list中的这个坐标元素置为null，以免下次再取到
                            examAnswerVos.set(randomInt, null);
                            examCreateAnswerJsonDtoList.add(ExamCreateAnswerJsonDto.builder()
                                    .option(options.get(i))
                                    .answerId(examAnswerVo.getId())
                                    .answerContent(examAnswerVo.getContent())
                                    .build());
                        }
                        ExamQuestion examQuestion = examQuestionService.selectById(qId);
                        AssertUtil.notNull(examQuestion, "有题目不存在，请重新操作");
                        assessmentPaperQuestionService.insert(AssessmentPaperQuestion.builder()
                                .assessmentPaperId(assessmentPaperId)
                                .questionId(qId)
                                .questionType(examQuestion.getType())
                                .provideAnswers(JSONUtil.toJsonStr(examCreateAnswerJsonDtoList))
                                .assessmentId(assessmentId)
                                .build());
                    }
                }

            });
        }

        assessmentPaperPersonService.insert(AssessmentPaperPerson.builder()
                .assessmentPaperId(assessmentPaperId)
                .userId(assessmentStartVo.getUserId())
                .userName(assessmentStartVo.getUserName())
                .status(AssessmentPersonStatusEnum.UN_SUBMIT.getCode().byteValue())
                .assessmentId(assessmentId)
                .submitTime(now)
                .build());

        return assessmentPaperId;
    }

    @Override
    public AssessmentDoingVo singleDetail(Long assessmentId, Long userId) {
        //试卷
        AssessmentPaper assessmentPaper = selectByUserIdAndAssessmentId(userId, assessmentId);
        if (Objects.isNull(assessmentPaper)) {
            return null;
        }
        AssertUtil.notNull(assessmentPaper, "此次考核不存在或者已被删除");
        Long assessmentPaperId = assessmentPaper.getId();

        List<AssessmentDoingVo.ContentNewVo> contentVoList = new ArrayList<>();
        if (Objects.nonNull(assessmentPaper.getWarehouseId())) {
            //找出这张试卷的生成题目
            List<AssessmentPaperQuestionVo> assessmentPaperQuestionVos = assessmentPaperQuestionService.selectList(AssessmentPaperQuestionSearchVo.builder()
                    .assessmentPaperId(assessmentPaperId)
                    .build());
            AssertUtil.check(CollectionUtils.isEmpty(assessmentPaperQuestionVos), "此次考核试题异常");
            //找试卷-人员结果表，以此确定此人有没有提交过考试
            Integer count = assessmentPaperPersonResultService.count(AssessmentPaperPersonResultSearchVo.builder()
                    .assessmentPaperId(assessmentPaperId)
                    .userId(userId)
                    .build());
            //是否已经考试
            boolean isStart = count > 0;
            assessmentPaperQuestionVos.forEach(examPaperQuestionVo -> {
                //根据题目id找到题目内容
                ExamQuestion examQuestion = examQuestionService.selectById(examPaperQuestionVo.getQuestionId());
                //组装回显vo类
                AssessmentDoingVo.ContentNewVo contentVo = AssessmentDoingVo.ContentNewVo.builder()
                        .answers(JsonUtil.toArray(examPaperQuestionVo.getProvideAnswers(), ExamCreateAnswerJsonDto.class))
                        .questionId(examPaperQuestionVo.getQuestionId())
                        .questionContent(examQuestion.getContent())
                        .questionType(examPaperQuestionVo.getQuestionType())
                        .build();
                if (isStart) {
                    //如果已经考试，还要把这个人对这个题目的提交选项查找出来，进行页面的回显
                    List<AssessmentPaperPersonResultVo> examPaperPersonResultVos = assessmentPaperPersonResultService.selectList(AssessmentPaperPersonResultSearchVo.builder()
                            .assessmentPaperQuestionId(examPaperQuestionVo.getId())
                            .assessmentPaperId(assessmentPaperId)
                            .build());
                    if (!CollectionUtils.isEmpty(examPaperPersonResultVos)) {
                        contentVo.setSelectAnswer(examPaperPersonResultVos.get(0).getSelectAnswer());
                    }
                }
                contentVoList.add(contentVo);
            });
        }

        //病例id
        String digitalSliceCaseIds = assessmentPaper.getDigitalSliceCaseIds();
        //病例列表
        List<DigitalSliceCaseVo> digitalSliceCaseList = null;
        if (StringUtils.isNotBlank(digitalSliceCaseIds)) {
            List<String> s = Arrays.asList(digitalSliceCaseIds.split(","));
            //按照病例id查询出来的
            digitalSliceCaseList = digitalSliceCaseService.selectOnlyList(DigitalSliceCaseSearchVo.builder()
                    .ids(s.stream().map(Long::valueOf).collect(Collectors.toList()))
                    .build());
        }
        return AssessmentDoingVo.builder()
                .code(assessmentPaper.getCode())
                .content(contentVoList)
                .status(assessmentPaper.getStatus())
                .assessmentId(assessmentId)
                .digitalSliceCaseList(digitalSliceCaseList)
                .build();
    }

    @Override
    public AssessmentWebDetailVo mainDetail(AssessmentPaperPersonSearchVo assessmentPaperPersonSearchVo) {
        Assessment assessment = assessmentService.selectById(assessmentPaperPersonSearchVo.getAssessmentId());
        AssertUtil.notNull(assessment, "此次考核不存在或者已被删除");
        //平均分
        BigDecimal avgScore = assessmentPaperPersonService.selectAvgScoreByAssessmentId(assessmentPaperPersonSearchVo.getAssessmentId());
        //完成率
        //所有人的数目
        List<String> projectList = Arrays.asList(assessment.getDoPersonIds().split(","));
        //已提交与已打分的数目
        Integer alreadySubmitCount = assessmentPaperPersonService.count(AssessmentPaperPersonSearchVo.builder()
                .assessmentId(assessment.getId())
                .statusList(Arrays.asList(AssessmentPersonStatusEnum.ALREADY_SUBMIT.getCode().byteValue(), AssessmentPersonStatusEnum.SCORE.getCode().byteValue()))
                .build());
        BigDecimal endRate = new BigDecimal(new BigDecimal(alreadySubmitCount).divide(new BigDecimal(projectList.size()), 2, RoundingMode.HALF_UP).doubleValue() * 100 + "");
        //合格的人数
        Integer upCount = this.countUpByAssessmentId(assessment.getId());
        //合格率 
        BigDecimal upRate = new BigDecimal(new BigDecimal(upCount).divide(new BigDecimal(projectList.size()), 2, RoundingMode.HALF_UP).doubleValue() * 100 + "");
        //考生试卷列表数据
        Page<AssessmentPaperPersonVo> assessmentPaperPersonVoPage = assessmentPaperPersonService.selectPage(assessmentPaperPersonSearchVo);
        return AssessmentWebDetailVo.builder()
                //是否能阅卷
                .weatherCanReviewer(Arrays.asList(assessment.getReviewerIds().split(",")).contains(CurrentUserHolder.getUser().getId() + ""))
                .avgScore(avgScore)
                .endRate(endRate)
                .upRate(upRate)
                .assessmentPaperPersonPage(assessmentPaperPersonVoPage)
                .build();
    }

    @Transactional(rollbackFor = Exception.class, value = "localTransactionManager")
    @Override
    public boolean score(AssessmentPaperDoScoreVo assessmentPaperDoScoreVo) {
        Assessment assessment = assessmentService.selectById(assessmentPaperDoScoreVo.getAssessmentId());
        AssertUtil.notNull(assessment, "此次考核不存在或者已被删除");
        //试卷
        AssessmentPaper assessmentPaper = assessmentPaperService.selectByUserIdAndAssessmentId(assessmentPaperDoScoreVo.getDoUserId(), assessment.getId());
        AssertUtil.notNull(assessmentPaper, "此次考核不存在或者已被删除");
        List<String> reviewerIds = Arrays.asList(assessment.getReviewerIds().split(","));
        AssertUtil.check(!reviewerIds.contains(assessmentPaperDoScoreVo.getReviewerId() + ""), "你没有权限进行阅卷打分");
        //这个做卷人提交的数字切片结果记录
        List<AssessmentDscPaperPersonVo> assessmentDscPaperPersonVos = assessmentDscPaperPersonService.selectList(AssessmentDscPaperPersonSearchVo.builder()
                .assessmentId(assessment.getId())
                .userId(assessmentPaperDoScoreVo.getDoUserId())
                .build());
        AssertUtil.check(CollectionUtil.isEmpty(assessmentDscPaperPersonVos), "此做卷人还没有提交试卷");
        List<AssessmentPaperPersonVo> assessmentPaperPersonVos = assessmentPaperPersonService.selectList(AssessmentPaperPersonSearchVo.builder()
                .assessmentId(assessment.getId())
                .userId(assessmentPaperDoScoreVo.getDoUserId())
                .build());
        AssertUtil.check(CollectionUtil.isEmpty(assessmentPaperPersonVos), "此做卷人还没有提交试卷");
        //具体数据
        List<AssessmentPaperDoScoreVo.DscScoreVo> scoreList = assessmentPaperDoScoreVo.getScoreList();
        //打分的和
        final Integer[] scoreSum = {0};
        //把提交的评语、打分保存起来
        scoreList.forEach(dscScoreVo -> {
            scoreSum[0] = scoreSum[0] + dscScoreVo.getScore();
            assessmentDscPaperPersonService.score(DscScoreDto.builder()
                    .assessmentId(assessment.getId())
                    .caseId(dscScoreVo.getId())
                    .doUserId(assessmentPaperDoScoreVo.getDoUserId())
                    .comment(dscScoreVo.getComment())
                    .commentRecordFilePath(dscScoreVo.getCommentRecordFilePath())
                    .score(dscScoreVo.getScore())
                    .status(AssessmentPersonStatusEnum.SCORE.getCode().byteValue())
                    .build());
        });
        //总分，包含题库分与数字切片分
        int all = assessmentPaperPersonVos.get(0).getTkScore() + scoreSum[0];
        assessmentPaperPersonService.updateByPrimaryKeySelective(AssessmentPaperPerson.builder()
                .id(assessmentPaperPersonVos.get(0).getId())
                .dscScore(scoreSum[0])
                .score(all)
                .status(AssessmentPersonStatusEnum.SCORE.getCode().byteValue())
                .result(all >= assessment.getAcceptanceLine() ? "合格" : "不合格")
                .build()
        );
        //修改试卷的状态
        assessmentPaperService.updateByPrimaryKeySelective(AssessmentPaper.builder()
                .id(assessmentPaper.getId())
                .status(AssessmentPersonStatusEnum.SCORE.getCode().byteValue())
                .build());
        return true;
    }

    @Override
    public List<AssessmentAnswerOfDigitalSliceCaseVo> selectAssessmentAnswerOfDigitalSliceCaseListByCondition(Long assessmentId, Long doUserId) {
        Assessment assessment = assessmentService.selectById(assessmentId);
        if (Objects.isNull(assessment)) {
            return Collections.emptyList();
        }
        AssessmentPaper assessmentPaper = this.selectByUserIdAndAssessmentId(doUserId, assessmentId);
        if (Objects.isNull(assessmentPaper)) {
            return Collections.emptyList();
        }
        //数字切片的病例ID列表
        String digitalSliceCaseIds = assessmentPaper.getDigitalSliceCaseIds();
        //病例列表
        List<String> s = Arrays.asList(digitalSliceCaseIds.split(","));
        //按照病例id查询出来的
        List<DigitalSliceCaseVo> digitalSliceCaseList = digitalSliceCaseService.selectOnlyList(DigitalSliceCaseSearchVo.builder()
                .ids(s.stream().map(Long::valueOf).collect(Collectors.toList()))
                .build());
        if (CollectionUtil.isNotEmpty(digitalSliceCaseList)) {
            //循环病例
            return digitalSliceCaseList.stream().map(digitalSliceCaseVo -> {
                AssessmentAnswerOfDigitalSliceCaseVo assessmentAnswerOfDigitalSliceCaseVo = new AssessmentAnswerOfDigitalSliceCaseVo();
                BeanUtils.copyProperties(digitalSliceCaseVo, assessmentAnswerOfDigitalSliceCaseVo);
                //查出这个做卷人在这次考核中，填写的这个病例的答案，组装出来
                List<AssessmentDscPaperPersonVo> assessmentDscPaperPersonVos = assessmentDscPaperPersonService.selectList(AssessmentDscPaperPersonSearchVo.builder()
                        .assessmentId(assessmentId)
                        .userId(doUserId)
                        .caseId(digitalSliceCaseVo.getId())
                        .build());
                if (CollectionUtil.isNotEmpty(assessmentDscPaperPersonVos)) {
                    assessmentAnswerOfDigitalSliceCaseVo.setAnswer(assessmentDscPaperPersonVos.get(0).getAnswer());
                    assessmentAnswerOfDigitalSliceCaseVo.setAnswerRecordFilePath(assessmentDscPaperPersonVos.get(0).getAnswerRecordFilePath());
                }
                return assessmentAnswerOfDigitalSliceCaseVo;
            }).collect(Collectors.toList());
        }
        return null;
    }

    @Override
    public Integer countUpByAssessmentId(Long assessmentId) {
        return mapper.countUpByAssessmentId(assessmentId);
    }

}